//
//  RHMorePoductCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/11/30.
//

#import "RHMorePoductCell.h"
@interface RHMorePoductCell()
@property (nonatomic, strong) UIImageView   *productImgView;

@property (nonatomic, strong) QMUILabel     *productNameLab;

@property (nonatomic, strong) QMUILabel     *productdescLab;

@end
@implementation RHMorePoductCell
-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        [self setupUI];
    }
    return self;
}

-(void)setDic:(NSDictionary *)dic
{
    _dic = dic;
    self.productImgView.image = [UIImage imageNamed:dic[CellIcon]];
    self.productNameLab.text = dic[CellTitle];
    self.productdescLab.hidden = ![dic[@"isNew"] boolValue];
}

-(void)setupUI
{
    kWeakSelf;
    self.contentView.backgroundColor = CFTabViewBgColor;
    
    UIView *bgView = [[UIView alloc] init];
    [bgView setBackgroundColor:UIColor.whiteColor];
    [bgView.layer setCornerRadius:8];
    [self.contentView addSubview:bgView];
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsZero);
    }];
    
    _productNameLab = [[QMUILabel alloc]init];
    _productNameLab.text = @"产品 A".rh_localized;
    _productNameLab.font = kSYSTEMFONT(15);
    _productNameLab.numberOfLines = 0;
    _productNameLab.textColor = kColorRGB(80, 80, 80);
    _productNameLab.textAlignment = NSTextAlignmentCenter;
    [bgView addSubview:_productNameLab];
    
    _productImgView = [[UIImageView alloc] init];
    [_productImgView setBackgroundColor:UIColor.whiteColor];
    [_productImgView.layer setCornerRadius:8];
    [_productImgView.layer setMasksToBounds:YES];
    _productImgView.image = kImage(@"Home_guangao-1");
    _productImgView.contentMode = UIViewContentModeScaleAspectFit;
    [bgView addSubview:_productImgView];
    
    NSLog(@"--->%f",kScaleW(15));
    [_productImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(kScaleW(15));
        make.right.mas_equalTo(-kScaleW(15));
        make.top.mas_offset(kScaleW(20));
        make.bottom.equalTo(weakSelf.productNameLab.mas_top).offset(kScaleW(-10));
    }];
    
    
    
   
    [_productNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_equalTo(-15);
        make.bottom.mas_offset(-15);
        make.height.offset(25);
     }];
    
    _productdescLab = [[QMUILabel alloc]init];
    _productdescLab.text = @"new ";
    _productdescLab.font = kSYSTEMFONT(12);
    _productdescLab.numberOfLines = 0;
    _productdescLab.textColor = [UIColor whiteColor];
    _productdescLab.textAlignment = NSTextAlignmentCenter;
    _productdescLab.backgroundColor = kCOLOR_HEX(@"FA3040");
    _productdescLab.layer.cornerRadius = 3;
    _productdescLab.layer.masksToBounds = YES;
    [bgView addSubview:_productdescLab];
    
    [_productdescLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(5);
        make.top.mas_offset(5);
        
     }];
}


@end
